<?php 

include("calendrier.php");
include_once("reservation.php");



$cal = new Calendrier();
$calendrier = $cal->getAllDay($cal->getCurrentYear());

if($sql->isAdmin($_COOKIE["m2l"])) {
    $vue = 4;
    $resa = Database::getAllReservationForAssoc($sql->getIdAssoc($_COOKIE["m2l"])->numero_association, $cal->getCurrentYear(), $cal->getCurrentMonth());
}
else {
    $vue = 6;
    $resa = Database::checkMyNextReservation($_COOKIE["m2l"], $cal->getCurrentYear(), $cal->getCurrentMonth());
}

?>
        <div id="calendar">
        	<?php echo '<table class="calendrier" id="containerCalendrier'.$vue.'">' ?>
        		<tr valign="top">
              <?php 
              $cpt = 1;


           		for($i = 0; $i < $vue; $i++) {
            	echo '<td class="tdCalendar'.$vue.'">';
                echo $cal->getCalendrier($i, $cal->getCurrentYear(), ($cal->getCurrentMonth()+$i), $resa);
                
                echo "</td>";
                
                if($vue == 4) {
                	if($cpt%2 == 0 && $cpt != 4) {
						echo "</tr>";
	                	echo "<tr valign='top'>";
	                }
                } else {
                	if($cpt%3 == 0 && $cpt != 6) {
	                	echo "</tr>";
	                	echo "<tr valign='top'>";
               		}
                }
                
                $cpt++;
            }
        ?>
    		</tr>
    	</table>

    </div>